package org.foreningsgatan.genetics.grid;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.foreningsgatan.genetics.Program;
import org.foreningsgatan.genetics.SimulationEnvironment;
import org.gridgain.grid.GridJob;

public class ProgramsWithEnvironment implements Serializable {
	private Collection<Program<? extends Serializable, ? extends Serializable>> programs;
	private SimulationEnvironment<? extends Serializable, ? extends Serializable> environment;

	public <T extends Serializable, S extends Serializable> ProgramsWithEnvironment(Collection programs, SimulationEnvironment<T, S> environment) {
		this.programs = programs;
		this.environment = environment;
	}

	public Collection<? extends GridJob> split() {
        List<GridJob> jobs = new ArrayList<GridJob>(programs.size());
        Collection<Program<? extends Serializable, ? extends Serializable>> programs2 = programs; 
		for (Program program : programs2) {
            jobs.add(new ProgramTask(environment, program));
			
		}
		return jobs;
	}
	
	
}
